import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { HydratedDocument } from 'mongoose'

export type MenuDocument = HydratedDocument<Menu>

@Schema()
export class Menu {
  @Prop({ unique: true })
  public id: string

  @Prop()
  public path: string

  @Prop({ unique: true })
  public name: string

  @Prop()
  public component: string

  @Prop()
  public redirect: string

  @Prop()
  public pid: string

  @Prop({ type: { icon: String, title: String, showLink: Boolean } })
  public meta: {
    icon: string
    title: string
    showLink: boolean
  }
}

export const MenuSchema = SchemaFactory.createForClass(Menu)
